package org.example.curriculum_design_6_16.config;

import org.springframework.context.annotation.Configuration;

/**
 * 社会服务配置类
 * 管理评分规则相关的常量配置
 */
@Configuration
public class SocialServiceConfig {

    // 分数上限常量
    public static final double BASE_SCORE_MAX = 15.0; // 基础分上限
    public static final double ADDITIONAL_SCORE_MAX = 5.0; // 附加分上限
    public static final double TOTAL_SCORE_MAX = 20.0; // 总分上限
    public static final double ABSENCE_PENALTY = 0.5; // 缺勤扣分

    // 时长计算常量
    public static final double FULL_YEAR_DURATION = 1.0; // 满一学年
    public static final double HALF_YEAR_DURATION = 0.5; // 满一学期
    public static final double HALF_SCORE_RATIO = 0.5; // 半学期分数比例

    // 等级评定标准
    public static final double EXCELLENT_THRESHOLD = 18.0; // 优秀分数线
    public static final double GOOD_THRESHOLD = 15.0; // 良好分数线
    public static final double PASS_THRESHOLD = 12.0; // 合格分数线

    // 特殊规则分数
    public static final double VOLUNTEER_SERVICE_SCORE = 0.2; // 志愿服务分数
    public static final double LARGE_ACTIVITY_SCORE = 0.8; // 大型活动分数
    public static final double AWARD_ACTIVITY_SCORE = 0.2; // 获奖活动分数
    public static final double ACADEMIC_CONFERENCE_SCORE = 0.5; // 学术会议工作人员分数

    // 职位类分数配置
    public static final double GRADUATE_PRESIDENT_SCORE = 3.0; // 校研究生会主席团成员
    public static final double GRADUATE_LEADER_SCORE = 2.0; // 校研究生会部门负责人
    public static final double GRADUATE_MEMBER_SCORE = 1.0; // 校研究生会部门成员
    public static final double PARTY_WORKER_SCORE = 2.0; // 党务工作者
    public static final double EMPLOYMENT_ASSISTANT_SCORE = 2.0; // 就业工作助手
    public static final double ACTING_MONITOR_SCORE = 2.0; // 代理班长
    public static final double PART_TIME_COUNSELOR_SCORE = 3.0; // 兼职辅导员
    public static final double STUDENT_ASSISTANT_SCORE = 2.0; // 学生工作助理
    public static final double ADMIN_ASSISTANT_SCORE = 2.0; // 助管
    public static final double TEACHING_ASSISTANT_SCORE = 2.0; // 助教
    public static final double RESEARCH_ASSISTANT_SCORE = 1.0; // 助研
    public static final double CLASS_MONITOR_SCORE = 2.0; // 班级班长
    public static final double CLASS_SECRETARY_SCORE = 2.0; // 团支书
    public static final double CLASS_COMMITTEE_SCORE = 1.0; // 其他班委

    // 状态常量
    public static final int STATUS_PENDING = 0; // 待审核
    public static final int STATUS_APPROVED = 1; // 已通过
    public static final int STATUS_REJECTED = 2; // 已拒绝

    // 规则类型常量
    public static final String RULE_TYPE_POSITION = "position"; // 职位类
    public static final String RULE_TYPE_ACTIVITY = "activity"; // 活动类
    public static final String RULE_TYPE_OTHER = "other"; // 其他

    // 学年范围常量
    public static final String SCOPE_CURRENT = "current"; // 仅当前学年
    public static final String SCOPE_ALL = "all"; // 所有学年

    // 时长要求常量
    public static final int DURATION_REQUIRED_YES = 1; // 需要时长
    public static final int DURATION_REQUIRED_NO = 0; // 不需要时长

    // 启用状态常量
    public static final int ACTIVE_YES = 1; // 启用
    public static final int ACTIVE_NO = 0; // 禁用

    /**
     * 根据时长计算职位类分数
     * @param baseScore 基础分数
     * @param duration 服务时长
     * @return 计算后的分数
     */
    public static double calculatePositionScore(double baseScore, double duration) {
        if (duration >= FULL_YEAR_DURATION) {
            return baseScore;
        } else if (duration >= HALF_YEAR_DURATION) {
            return baseScore * HALF_SCORE_RATIO;
        } else {
            return 0.0;
        }
    }

    /**
     * 检查分数是否超过上限
     * @param score 分数
     * @param maxScore 上限
     * @return 限制后的分数
     */
    public static double limitScore(double score, double maxScore) {
        return Math.min(score, maxScore);
    }

    /**
     * 检查分数是否为负数
     * @param score 分数
     * @return 非负数分数
     */
    public static double ensureNonNegative(double score) {
        return Math.max(score, 0.0);
    }
} 